package com.example.demo.demo.integer;

/**
 *
 * int和Integer的区别
 * 1、Integer是int的包装类，int则是java的一种基本数据类型
 * 2、Integer变量必须实例化后才能使用，而int变量不需要
 * 3、Integer实际是对象的引用，当new一个Integer时，实际上是生成一个指针指向此对象；而int则是直接存储数据值
 * 4、Integer的默认值是null，int的默认值是0
 *
 * @author luowj12
 * @since 2021/6/17 10:06
 */
public class IntegerTest {

    public static void main(String[] args) {
        /*Integer i = new Integer(100);
        Integer j = new Integer(100);
        System.out.println(i == j); //false*/
        /*Integer i = 100;
        Integer j = 100;
        System.out.println(i == j); //true*/
        Integer i = new Integer(100);
        int j = 100;
        System.out.println(i == j); //true
        /*Integer i = new Integer(100);
        Integer j = 100;
        System.out.println(i == j); //false
        System.out.println(i.equals(j)); //true*/
        /*Integer i2 = 160;
        Integer j2 = 160;
        System.out.println(i2 == j2); //false
        System.out.println(i2.equals(j2)); //true*/
        /*
        Integer i1 = 128;
        Integer j1 = 128;
        System.out.println(i1 == j1); //false*/
    }

}
